//
//  ZFCustomControlView.m
//  ZFPlayer_Example
//
//  Created by 紫枫 on 2019/6/5.
//  Copyright © 2019 紫枫. All rights reserved.
//

#import "WWANCoverView.h"
#import "UXUtilities.h"
@interface WWANCoverView ()

@end

@implementation WWANCoverView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor =  [UIColor colorWithRed: 31/255 green: 31/255 blue: 36/255 alpha: 1];
        [self addAllSubViews];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [self resetControlView];
}

- (void)dealloc {

}

- (void)resetControlView {
    CGFloat Lb_H = 20;
    CGFloat Btn_w = 120;
    CGFloat Btn_H = 55;
    CGFloat min_view_w = self.bounds.size.width;
    CGFloat min_view_h = self.bounds.size.height;
    CGFloat allHeight = Btn_H + 20 + 10 + (Lb_H*2);

    self.titleLb.frame = CGRectMake(0, (min_view_h - allHeight)/2, min_view_w, Lb_H);
    self.contentLb.frame = CGRectMake(0, CGRectGetMaxY(self.titleLb.frame) + 10, min_view_w, Lb_H);
    self.playBtn.frame = CGRectMake((min_view_w - Btn_w)/2, CGRectGetMaxY(self.contentLb.frame) + 10, Btn_w, Btn_H);
}

/// 添加所有子控件
- (void)addAllSubViews {
    [self addSubview:self.titleLb];
    [self addSubview:self.contentLb];
    [self addSubview:self.playBtn];

}

/// 添加所有子控件
- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLb.text = @"您正在使用移动网络";
        _titleLb.textAlignment = NSTextAlignmentCenter;
        _titleLb.textColor = [UIColor colorWithRed: 245/255 green: 245/255 blue: 245/255 alpha: 1];
        _titleLb.font = [UIFont systemFontOfSize:16];
    }
    return  _titleLb;
}
- (UILabel *)contentLb {
    if (!_contentLb) {
        _contentLb = [[UILabel alloc] initWithFrame:CGRectZero];
        _contentLb.text = @"继续观看会消耗通用流量,请确认是否继续";
        _contentLb.textAlignment = NSTextAlignmentCenter;
        _contentLb.textColor = [UIColor colorWithRed: 119/255 green: 119/255 blue: 119/255 alpha: 1];
        _titleLb.font = [UIFont systemFontOfSize:12];
    }
    return  _contentLb;
}
- (UIButton *)playBtn {
    if (!_playBtn) {
        _playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _playBtn.backgroundColor = [UIColor colorWithRed: 119/255 green: 119/255 blue: 119/255 alpha: 1];
        [_playBtn setTitle:@"继续观看 ▶" forState:UIControlStateNormal];
        [_playBtn setTitleColor:[UIColor colorWithRed: 141/255 green: 141/255 blue: 141/255 alpha: 1] forState:UIControlStateNormal];
        _playBtn.layer.cornerRadius = 5;
        _playBtn.titleLabel.font = [UIFont systemFontOfSize:20];
    }
    return  _playBtn;
}

@end
